<template>
  <div class="full-box shadow-box padding-box">
    <Form v-if="id == 0"></Form>
    <template v-else>
      <div class="operate-bar">
        <div class="btn-group">
          <el-button type="info" @click="goBack">返回</el-button>
        </div>
      </div>
      <el-collapse v-if="info" v-model="activeNames" :accordion="false">
        <el-collapse-item title="检查整改单详情" :name="1">
          <div class="desc">
            <label>整改单编号：</label>
            <span>{{ info.mend_code }}</span>
          </div>
          <div class="desc">
            <label>整改项目：</label>
            <span>{{ info.object_name }}</span>
          </div>
          <div class="desc">
            <label>问题来源：</label>
            <span>{{ questionSource(info.problem_source) }}</span>
          </div>
          <div class="desc">
            <label>问题类型：</label>
            <span>
              <span class="question-type">
                {{ info.problem_type_safety == 1 ? "工程安全" : "" }}
              </span>
              <span class="question-type">
                {{ info.problem_type_quality == 1 ? "工程质量" : "" }}
              </span>
              <span class="question-type">
                {{ info.problem_type_build == 1 ? "文明施工" : "" }}
              </span>
              <span class="question-type">
                {{ info.problem_type_duty == 1 ? "人员到岗" : "" }}
              </span>
            </span>
          </div>
          <div class="desc">
            <label>疑似事项：</label>
            <span v-if="info.recontract == 1">非法转包</span>
            <span
              style="margin: 0 -20px"
              v-if="info.recontract == 1 && info.subcontract == 1"
            >
              |
            </span>
            <span v-if="info.subcontract == 1">违法分包</span>
          </div>
          <div class="desc">
            <label>问题描述：</label>
            <span>{{ info.problem_desc }}</span>
          </div>
          <div class="desc">
            <label>相同问题重复次数：</label>
            <span>{{ info.repeat_count }}</span>
          </div>
          <div class="desc">
            <label>检查单位：</label>
            <span>{{ info.inspect_unit }}</span>
          </div>
          <div class="desc">
            <label>检查人员：</label>
            <span>{{ info.inspector }}</span>
          </div>
          <div class="desc">
            <label>整改要求：</label>
            <span>{{ info.mend_require }}</span>
          </div>
          <div class="desc">
            <label>反馈日期要求：</label>
            <span>{{ info.feedback_date_require }}</span>
          </div>
          <div class="desc">
            <label>完成日期要求：</label>
            <span>{{ info.finish_date_require }}</span>
          </div>
          <div class="desc">
            <label>登记时间：</label>
            <span>{{ info.regist_date }}</span>
          </div>
          <div class="desc">
            <label>状态：</label>
            <span>{{ info.status_text }}</span>
          </div>

          <div class="desc">
            <label>评价等级：</label>
            <span>{{ info.appraise_grade }}</span>
          </div>
        </el-collapse-item>
        <el-collapse-item
          v-if="info.mendList && info.mendList.length > 0"
          title="反馈单"
          :name="2"
        >
          <el-tabs v-model="active" type="border-card" tab-position="top">
            <el-tab-pane
              v-for="(item, index) in info.mendList"
              :key="index"
              :label="`第 ${info.mendList.length - index} 次反馈`"
              :name="item.id"
            >
              <div class="desc">
                <label>反馈信息：</label>
                <span>{{ item.feedback_content }}</span>
              </div>
              <div class="desc">
                <label>反馈时间：</label>
                <span>{{ item.feedback_date }}</span>
              </div>
              <el-divider
                direction="horizontal"
                content-position="left"
              ></el-divider>
              <template v-if="item.check_status != ''">
                <div class="desc">
                  <label>审核结果：</label>
                  <span>{{ item.check_status_text }}</span>
                </div>
                <div class="desc">
                  <label>评价信息：</label>
                  <span>{{ item.check_content }}</span>
                </div>
                <div class="desc">
                  <label>评价时间：</label>
                  <span>{{ item.check_time }}</span>
                </div>
              </template>
            </el-tab-pane>
          </el-tabs>
        </el-collapse-item>
      </el-collapse>
    </template>
  </div>
</template>

<script>
import { getCheckAndRectifyDetails } from "@/api/CheckAndRectify/Index";
import Form from "./Form.vue";
import { questionSource } from "@/utils/typeHelper";
export default {
  name: "CheckAndRectifyDetails",
  components: {
    Form,
  },
  data() {
    return {
      id: 0,
      pageType: 0,
      active: "",
      activeNames: [1],
      info: null,
    };
  },
  methods: {
    questionSource,
    initData() {
      getCheckAndRectifyDetails({ id: this.id }).then((res) => {
        this.info = res.data;
        if (this.info.mendList && this.info.mendList.length > 0) {
          this.activeNames = [1, 2];
          this.active = this.info.mendList[0].id;
        }
      });
    },
    goBack() {
      switch (parseInt(this.pageType)) {
        case 999:
          this.$router.go(-1);
          break;
        default:
          this.$router.push("/checkAndRectifyRegistration");
          break;
      }
    },
  },
  created() {
    this.id = this.$route.params.id;
    this.pageType = this.$route.params.type;

    if (this.id > 0) {
      this.initData();
    }
  },
};
</script>

<style lang="scss" scoped>
.question-type-wrapper {
  line-height: 50px;
}
.question-type {
  margin: 0 10px;
}
</style>
